package study.javase.net.ip;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 *
 * @author LiShaowen
 * @date 2020/9/4 22:45
 */
public class IpTest {
    public static void main(String[] args) throws UnknownHostException {
        InetAddress address = InetAddress.getLocalHost();
        System.out.println("本机地址"+address.getHostAddress());
        System.out.println("计算机名"+address.getHostName());

        // 根据域名得到InetAddress对象
        System.out.println(address = InetAddress.getByName("github.com"));
    }
}
